package hs.bank.Data;

import hs.bank.Entity.Role;
import hs.bank.Entity.User_Role;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface User_Role_Mapper {

    @Insert("insert into user_role(userId, roleId) value(#{userId}, #{roleId})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void save(User_Role user_role);

    @Select("select roleId,roleName from role where roleId in " +
            "(select roleId from user_role where userId in " +
            "(select userId from user where username = #{username}));")
    Role getUserRoleByUsername(@Param("username") String username);

}
